home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Pictures / TIFF / Tiff Utilties / Tiff Window DEMO / Main color.c < prev    next >
C/C++ Source or Header  |  1990-04-23  |  4KB  |  132 lines

  1. /*
  2.         TIFF Window Reader Program
  3.         By:    Jim Griffin
  4.             Indianapolis, IN
  5.             IJDG400 @ Indycms.bitnet.edu
  6.             JimGriffin on America On Line
  7.             
  8.         Copyright © 1990 by Jim Griffin
  9.         
  10.         This program may not be sold or given away for profit.
  11.         Feel free to distribute the program and source code among your friends,
  12.         but all files must be included in the exchange.
  13.         Keep all the files together.
  14.         All rights reserved.
  15.             
  16.  
  17.  
  18. I wrote this program to teach myself about intricacies of creating Offscreen CGrafPorts 
  19. and reading TIFF files.
  20. I don't claim that this program demonstrates the best method of creating and displaying 
  21. Offscreen CGrafPorts, merely that this is one of the ways.  Feel free to use the knowledge 
  22. you learn here in other programs you may write.  My only desire is that you will 
  23. release your code so that others may also gain new knowledge in programing Macintosh 
  24. computers.
  25.  
  26. To create this program I made extensive modifications to the code from 
  27. the "ShowOff" source code in the Developer's Source Code library that 
  28. is in America Online.
  29.  
  30.  
  31.     NOTE: I assume that you will have a copy of Inside Macintosh Vols 1 thru 5 handy.
  32.             If not then you might have difficulty understanding some of the color
  33.             routines such as GetColor();, GetAuxWin(aWindow, &some_new_colors);, and
  34.             all the rest.
  35.             I also assume that you will understand C statements that look like
  36.  
  37.             (**(**some_new_colors).awCTable).ctTable[0].value = 0;
  38.  
  39.             If the above statement makes your eyes cross, then perhaps this program 
  40.             isn't for you.  On the other hand if you want to learn how use statements
  41.             like that then you should try to read the program.
  42. */
  43.  
  44.  
  45. #define    NO_COLOR_QUICKDRAW 19601
  46. #include "my color.h"
  47. #include <OSUtil.h>
  48.  
  49. main()                    /*main program*/
  50. {
  51. SysEnvRec            what_is_there;
  52. CWindowPtr    who_is_in_front;
  53. extern CGrafPort    the_picture;
  54. Boolean                shift_colors;
  55.  
  56.  
  57.     init_color_demo();            /* initialize the Managers, prepare for program execution */
  58.     shift_colors = FALSE;
  59.     SysEnvirons(2, &what_is_there);
  60.     if(what_is_there.hasColorQD == FALSE)    /* This program must have Color 
  61.                                             QuickDraw to function, else it 
  62.                                             would crash and that would be 
  63.                                             bad.  Note that I only need 
  64.                                             Color QuickDraew, and not 
  65.                                             necessarily a color monitor. 
  66.                                             This program 
  67.                                             will run correctly on any 
  68.                                             macintosh with color Quickdraw, 
  69.                                             even an SE/30 which is obviously
  70.                                             a Black and White machine. 
  71.                                             Color QuickDraw will allow for 
  72.                                             the Black and White environment 
  73.                                             and display the TIFF file in a 
  74.                                             surprisingly good manner. you 
  75.                                             just don't get color. */
  76.     {
  77.         StopAlert(NO_COLOR_QUICKDRAW, 0L);
  78.         return;
  79.     }
  80.  
  81.     OpenWindow();    /*start with one open window, 
  82.                         OpenWindow will call my TIFF reader routine*/
  83.  
  84. /* Main event loop */
  85.     do
  86.     {
  87.         SystemTask();
  88.         who_is_in_front = (CWindowPtr)FrontWindow();
  89.  
  90.         if (!menusOK && (who_is_in_front == nil))
  91.         {
  92.             DisableItem (myMenus [fileM], closeItem);
  93.             DisableItem (myMenus [editM], 0);
  94.             menusOK = true;
  95.         }
  96.         if (GetNextEvent(everyEvent,&myEvent))
  97.             switch (myEvent.what) 
  98.             {
  99.  
  100.                 case mouseDown:
  101.                     do_mouse_down(&myEvent);
  102.                     break;
  103.                 case keyDown:
  104.                 case autoKey:
  105.                         if ((myEvent.modifiers & cmdKey) != 0)
  106.                             DoCommand(MenuKey(myEvent.message & charCodeMask));
  107.                         break;
  108.                         
  109.                 case activateEvt:
  110.                     do_activate(&myEvent);
  111.                     break;
  112.                     
  113.                 case updateEvt:
  114.                     do_update(&myEvent);
  115.                     break;
  116.  
  117.             }    /*switch myEvent.what*/
  118.  
  119.     }
  120.     while (!doneFlag);
  121.     ShowCursor();    /* Make certain the cursor is visible */
  122.     while(who_is_in_front = (CWindowPtr)FrontWindow())    /* Close ALL the open Windows!!! */
  123.     KillWindow(who_is_in_front);
  124.  
  125.     
  126.     return;
  127. } /*end of the main program modual*/
  128.  
  129.             
  130.  
  131.  
  132.